package com.familytreemangement.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * 人员关系表
 * @TableName family_relation
 */
@TableName(value ="family_relation")
@Data
public class FamilyRelation {
    /**
     * 关系ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 人员ID1
     */
    @TableField(value = "member_id1")
    private Integer memberId1;

    /**
     * 人员ID2
     */
    @TableField(value = "member_id2")
    private Integer memberId2;

    /**
     * 关系类型(关联common_data_item.id)
     */
    @TableField(value = "relation_type")
    private Integer relationType;

    /**
     * 逻辑删除（0-未删除,1-已删除）
     */
    @TableField(value = "is_deleted")
    private Integer isDeleted;

    /**
     * 创建时间
     */
    @TableField(value = "created_at")
    private LocalDateTime createdAt;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        FamilyRelation other = (FamilyRelation) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getMemberId1() == null ? other.getMemberId1() == null : this.getMemberId1().equals(other.getMemberId1()))
            && (this.getMemberId2() == null ? other.getMemberId2() == null : this.getMemberId2().equals(other.getMemberId2()))
            && (this.getRelationType() == null ? other.getRelationType() == null : this.getRelationType().equals(other.getRelationType()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getMemberId1() == null) ? 0 : getMemberId1().hashCode());
        result = prime * result + ((getMemberId2() == null) ? 0 : getMemberId2().hashCode());
        result = prime * result + ((getRelationType() == null) ? 0 : getRelationType().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", memberId1=").append(memberId1);
        sb.append(", memberId2=").append(memberId2);
        sb.append(", relationType=").append(relationType);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", createdAt=").append(createdAt);
        sb.append("]");
        return sb.toString();
    }
}